#{extends 'backend_main.html' /}
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" id="id" name="id" value="${sysMenu?.id}">
        <div class="layui-form-item">
            <label for="menu_name" class="layui-form-label">
                <span class="x-red">*</span>菜单名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="menu_name" name="menu_name" required="" lay-verify="required" autocomplete="off" class="layui-input"
                       value="${sysMenu?.menu_name}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="access_url" class="layui-form-label">
                <span class="x-red">*</span>访问地址
            </label>
            <div class="layui-input-inline">
                <input type="text" id="access_url" name="access_url" required="" lay-verify="required" autocomplete="off" class="layui-input"
                       value="${sysMenu?.access_url}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="update" lay-submit="">
                提交
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer','upload','laydate'], function(){
        var $ = layui.jquery;
        var form = layui.form,layer = layui.layer;
        var upload = layui.upload;
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#buy_date' //指定元素
        });
        //自定义验证规则
        form.verify({
            customer_name: function(value){
                if(value.length < 2){
                    return '客户姓名至少得2个字符啊';
                }
            }
        });
        //监听提交
        form.on('submit(update)', function(data){
            console.log(JSON.stringify(data.field));
            //发异步，把数据提交给php
            $.ajax({
                type:"POST",                      //请求类型
                url:"/SystemCenter/adminRuleEdit?v=update",                 //URL
                data:data.field,                  //传递的参数
                dataType:"json",                 //返回的数据类型
                success:function(data){          //data就是返回的json类型的数据
                    console.log(data);
                    layer.alert(data.msg, {icon: 6},function () {
                        parent.window.location.reload();
                    });
                },
                error:function(data){
                }
            });
            return false;
        });
    });
</script>